package controller.v1;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import util.PackageUtil;

@Controller
@RequestMapping("/v1")
public class AppUpdateController1 {
	
	@ResponseBody
	@RequestMapping(value="/appUpdate",method=RequestMethod.GET) 
	public Object appUpdate(HttpServletRequest request, HttpServletResponse response,String version,@RequestHeader (value="OS", required=false) String os){
		if( (!"ios".equals(os.toLowerCase())) && !"android".equals(os.toLowerCase())){
			return PackageUtil.packageParams(10000,"参数错误，请参考API文档","",""); 
		}
		Map map = new HashMap();
		//当前版本号
		map.put("version", "150");
		map.put("content", "1、商品多规格功能上线<br/>2、修复了一些问题");
		map.put("force", "Y");
		if("ios".equals(os.toLowerCase())){
			map.put("url", "https://itunes.apple.com/us/app/友米乐/id1269468214?l=zh&ls=1&mt=8");
		}else if("android".equals(os.toLowerCase())){
			map.put("url", "http://ymaccelerator.oss-cn-beijing.aliyuncs.com/update/fenxiao_1.5.0.apk");
		}
		return PackageUtil.packageParams(200,"successs",map,""); 
	}

}
